# Maintainer: Sébastien Luttringer
# Contributor: Andrea Zucchelli <zukka77@gmail.com>

pkgname=keepalived
pkgver=2.2.8
pkgrel=1
pkgdesc='Failover and monitoring daemon for LVS clusters'
arch=('loong64' 'x86_64')
url='https://www.keepalived.org/'
license=('GPL2')
backup=('etc/keepalived/keepalived.conf'
        'etc/sysconfig/keepalived')
makedepends=('ipset')
depends=('glibc' 'libnl' 'openssl' 'file' 'iptables' 'systemd-libs')
optdepends=('ipset: ipset support')
makedepends=('libnfnetlink' 'ipset' 'systemd')
options=('!emptydirs')
source=("https://www.keepalived.org/software/$pkgname-$pkgver.tar.gz")
sha256sums=('85882eb62974f395d4c631be990a41a839594a7e62fbfebcb5649a937a7a1bb6')

build() {
  # trick broken ./configure systemctl test
  printf "#!/bin/sh\necho -.mount\n" > systemctl
  chmod +x systemctl
  PATH=$PWD:$PATH

  cd "${pkgname}-${pkgver}"

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --sbindir=/usr/bin \
    --localstatedir=/var \
    --runstatedir=/run \
    --enable-json
  make
}

package() {
  cd "${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install

  # move conf file to correct name
  mv "${pkgdir}"/etc/keepalived/keepalived.conf{.sample,}

  # move examples to /usr/share
  install -d -m 0755 "${pkgdir}/usr/share/${pkgname}"
  mv "${pkgdir}/etc/keepalived/samples" "${pkgdir}/usr/share/$pkgname/samples"
}

# vim:set ts=2 sw=2 et:
